package io.github.aaron.commonadmin.base.vo;

/**
 * @Author: AaronF
 * @Date: 2025/08/19/23:35
 * @Description: 通用响应体
 */
public class ApiResponse<T> {

    private T data;

    private int code;

    private String msg;

    public static <R> ApiResponse<R> success(R data){
        return success(data,"成功");
    }

    public static <R> ApiResponse<R> success(R data,String msg){
        return new ApiResponse<>(data,200,msg);
    }

    public static <R> ApiResponse<R> error(R data){
        return error(data,"系统异常，请联系管理员");
    }

    public static <R> ApiResponse<R> error(R data,String msg){
        return new ApiResponse<>(data,500,msg);
    }

    private ApiResponse(T data, int code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
